package com.zmm.book.keep.dao;

import com.zmm.book.keep.model.Bill;
import com.zmm.book.keep.model.MonthBillDetail;
import com.zmm.book.keep.vo.BillResultVo;
import com.zmm.book.keep.vo.ConsumeDetailVo;
import com.zmm.book.keep.vo.ConsumeVo;
import com.zmm.book.keep.vo.DetailParamVo;
import com.zmm.common.base.model.Query;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author 900045
 * @description:
 * @name BillDao
 * @date By 2021-09-28 10:11:39
 */
@Mapper
public interface BillDao {
	
	/**
	 * 保存账单记录
	 * @author: 900045
	 * @date: 2021-09-28 17:49:04
	 * @throws 
	 * @param bill: 
	 * @return: java.lang.Integer
	 **/
	Integer insertBill(Bill bill);
	
	/**
	 * 更新账单记录
	 * @author: 900045
	 * @date: 2021-10-08 16:25:44
	 * @throws 
	 * @param bill: 
	 * @return: java.lang.Integer
	 **/
	Integer updateBill(Bill bill);

	/**
	 * 根据条件 condition 查询数据量
	 * @author: 900045
	 * @date: 2021-09-30 09:32:00
	 * @throws 
	 * @param queryBill: 
	 * @return: java.lang.Integer
	 **/
	Integer countBillList(Query<BillResultVo> queryBill);

	/**
	 * 根据条件 condition 查询数据
	 * @author: 900045
	 * @date: 2021-09-30 11:39:46
	 * @throws 
	 * @param queryBill: 
	 * @return: java.util.List<com.zmm.book.keep.model.Bill>
	 **/
	List<BillResultVo> searchBillList(Query<BillResultVo> queryBill);

	/**
	 * 根据 ID 获取账单详情
	 * @author: 900045
	 * @date: 2021-10-08 16:39:59
	 * @throws 
	 * @param recordId: 
	 * @return: com.zmm.book.keep.model.Bill
	 **/
	Bill selectOneBill(@Param("recordId") Integer recordId);

	/**
	 * 根据日期查询
	 * @description:
	 * @author: Zebulon
	 * @date: 2021-10-08 22:56:17
	 * @param date:
	 * @param detailParamVo:
	 * @return: java.math.BigDecimal
	 **/
    BigDecimal totalConsumeByDate(@Param("detailParamVo") DetailParamVo detailParamVo , @Param("date") String date);

    /**
	 * 根据方式查询消费详情
     * @description:
     * @author: Zebulon
     * @date: 2021-10-08 23:17:11
	 * @param detailParamVo:
     * @param mode:
	 * @param date:
     * @return: java.math.BigDecimal
     **/
	BigDecimal totalConsumeByModeAndDate(@Param("detailParamVo") DetailParamVo detailParamVo,@Param("mode") Integer mode, @Param("date") String date);

	/**
	 *  账单类型 详情
	 * @description:
	 * @author: Zebulon
	 * @date: 2021-10-08 23:24:51
	 * @param date:
	 * @param detailParamVo:
	 * @return: java.util.List<com.zmm.book.keep.vo.ConsumeDetailVo>
	 **/
	List<ConsumeDetailVo> consumeDetailByDate(@Param("date") String date, @Param("detailParamVo") DetailParamVo detailParamVo);

	/**
	 * 根据时间查询 总消耗 (有对象参数和字段参数 xml中 不能指定 parameterType 对象使用 . 的方式调用 / 字段直接使用)
	 * @author: 900045
	 * @date: 2021-10-09 15:02:03
	 * @throws 
	 * @param detailParamVo:
	 * @param startTime: 
	 * @param endTime: 
	 * @return: java.math.BigDecimal
	 **/
	BigDecimal totalConsumeByBetweenDate(@Param("detailParamVo") DetailParamVo detailParamVo,@Param("startTime") String startTime,
										 @Param("endTime") String endTime);

	/**
	 * 查询区间内的金额
	 * @author: 900045
	 * @date: 2021-10-09 15:10:57
	 * @throws 
	 * @param mode: 
	 * @param startTime: 
	 * @param endTime:
	 * @param detailParamVo:
	 * @return: java.math.BigDecimal
	 **/
	BigDecimal totalConsumeByModeAndBetweenDate(@Param("mode") Integer mode, @Param("detailParamVo") DetailParamVo detailParamVo,
												@Param("startTime") String startTime, @Param("endTime") String endTime);

	/**
	 * 根据时间查询 总消耗
	 * @author: 900045
	 * @date: 2021-10-09 15:15:05
	 * @throws 
	 * @param startTime: 
	 * @param endTime: 
	 * @param detailParamVo:
	 * @return: java.util.List<com.zmm.book.keep.vo.ConsumeDetailVo>
	 **/
	List<ConsumeDetailVo> consumeDetailByBetweenDate(@Param("startTime") String startTime, @Param("endTime") String endTime,
													 @Param("detailParamVo") DetailParamVo detailParamVo);
	
	/**
	 * 根据 date 和 type 查询月账单
	 * @author: 900045
	 * @date: 2021-10-28 14:44:32
	 * @throws 
	 * @param date: 
	 * @param type: 
	 * @param mode:   
	 * @return: com.zmm.book.keep.model.MonthBillDetail
	 **/
	MonthBillDetail collectBillByDateAndType(@Param("date") String date, @Param("type") Integer type, @Param("mode") Integer mode);

	/**
	 * 根据 date 和 form 查询月账单
	 * @author: 900045
	 * @date: 2021-10-28 14:52:02
	 * @throws 
	 * @param date: 
	 * @param form:
	 * @param mode:    
	 * @return: com.zmm.book.keep.model.MonthBillDetail
	 **/
	MonthBillDetail collectBillByDateAndForm(@Param("date") String date, @Param("form") String form, @Param("mode") Integer mode);
	
	
	// =========优化的方法
	
	/**
	 * 分组查询 type 为 28,30,31,26,17 mode 1
	 * @author: 900045
	 * @date: 2021-10-28 19:56:41
	 * @throws 
	 * @param date: 
	 * @param list:   
	 * @param mode: 
	 * @return: java.util.List<com.zmm.book.keep.model.MonthBillDetail>
	 **/
	List<MonthBillDetail> collectIncomeBillListByDate(@Param("date") String date,@Param("list") List<Integer> list,
													  @Param("mode") Integer mode);
	
	/**
	 * 查询 金额 总和
	 * @author: 900045
	 * @date: 2021-10-29 15:27:40
	 * @throws 
	 * @param date: 
	 * @param customerId:   
	 * @param list: 
	 * @return: java.math.BigDecimal
	 **/
	BigDecimal totalMoneyMonthBill(@Param("date") String date, @Param("customerId") Integer customerId, @Param("list") List<Integer> list);

	/**
	 * 查询消费集合
	 * @author: 900045
	 * @date: 2021-10-28 20:18:23
	 * @throws 
	 * @param date: 
	 * @param mode: 
	 * @return: java.util.List<com.zmm.book.keep.vo.ConsumeVo>
	 **/
	List<ConsumeVo> collectConsumeBillListByDate(@Param("date") String date, @Param("mode") Integer mode);
	
	
	// =========更新表结构后的查询方式
	
	/**
	 * 收集账单明细
	 * @author: 900045
	 * @date: 2021-10-29 11:40:12
	 * @throws 
	 * @param date: 
	 * @return: java.util.List<com.zmm.book.keep.model.MonthBillDetail>
	 **/
	List<MonthBillDetail> collectMonthBillDetail(@Param("date") String date);
}
